package niuke;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class 两种排序方法 {

    static int n;
    static String[] strings;

    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        n = Integer.parseInt(br.readLine());
        strings = new String[n];
        for(int i=0;i<n;i++){
            strings[i] = br.readLine();
        }
        br.close();
        boolean b1 = f1();
        boolean b2 = f2();
        if(b1 && !b2){
            System.out.println("lexicographically");
            return;
        }
        else if(!b1 && b2){
            System.out.println("lengths");
            return;
        }
        else if(b1 && b2){
            System.out.println("both");
            return;
        }
        else {
            System.out.println("none");
            return;
        }
    }

    //字典排序
    public static boolean f1(){
        int p=0;
        for(int i=0;i<n-1;i++){
            if(strings[i].charAt(p) > strings[i+1].charAt(p)){
                return false;
            }
            else if(strings[i].charAt(p) < strings[i+1].charAt(p)){
                continue;
            }
            else {
                if(check(i,i+1)){
                    continue;
                }
                else {
                    return false;
                }
            }
        }
        return true;
    }

    //长度排序
    public static boolean f2(){
        for(int i=0;i<n-1;i++){
            if(strings[i].length()>strings[i+1].length()){
                return false;
            }
        }
        return true;
    }

    //单独比较两个字符串是否满足字典排序
    public static boolean check(int n1,int n2){
        int length1 = strings[n1].length();
        int length2 = strings[n2].length();
        int min = length1>length2 ? length2 : length1;
        int i;
        for(i=1;i<min;i++){
            if(strings[n1].charAt(i) > strings[n2].charAt(i)){
                return false;
            }
            else if(strings[n1].charAt(i) < strings[n2].charAt(i)){
                return true;
            }
        }
        if(i == min && strings[n1].length() > strings[n2].length()){
            return false;
        }
        return true;
    }
}
